﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace SomaiNordeste.FabricaRacao.DomainModel.Repository
{
    public static class TableExtensionMethod
    {
        public static DataTable AdicionaInsumos(this List<Batida> batidas)
        {
            DataTable _table = new DataTable();
            _table.Columns.AddRange(Colunas());

            foreach (var insumo in batidas)
            {
                DataRow row = _table.NewRow();
                row["Data"] = insumo.Date;
                row["Desc."] = insumo.Descricao;
                row["Bat."] = insumo.BatidaN;
                row["Peso"] = insumo.KG_Total;
                _table.Rows.Add(row);
            }

            return _table;
        }



        private static DataColumn[] Colunas()
        {
            DataColumn[] columns = new DataColumn[4];

            DataColumn Date = new DataColumn();
            Date.ColumnName = "Data";
            columns[0] = Date;

            DataColumn Descricao = new DataColumn();
            Descricao.ColumnName = "Desc.";
            columns[1] = Descricao;

            DataColumn Batida = new DataColumn();
            Batida.ColumnName = "Bat.";
            columns[2] = Batida;

            DataColumn KG_Total = new DataColumn();
            KG_Total.ColumnName = "Peso";
            columns[3] = KG_Total;

            return columns;
        }
    }
}
